#include "downloadmanager.h"
#include <QDebug>


DownloadManager::DownloadManager(QObject *parent) : QObject(parent)
{
    qRegisterMetaType<MyData>("MyData");

    m_readDataThread = new ReadDataThread(this);
//    connect(m_readDataThread, &ReadDataThread::received, this, &DownloadManager::onReceived, Qt::QueuedConnection);
//    connect(m_readDataThread, &ReadDataThread::received, this, &DownloadManager::onReceived, Qt::DirectConnection);

    connect(m_readDataThread, &ReadDataThread::receivedMyData, this, [=](MyData t){
        qDebug() << "received from thread: " << t.desc;
    });
}

void DownloadManager::startDownload() {
    qDebug() << "DownloadManager::startDownload() " << QThread::currentThreadId();
    m_readDataThread->start();
}

void DownloadManager::onReceived(int t)
{

}
